Method and circuit system for compressing video signals based on adaptive compression rate

ABSTRACT

A method for compressing video signals based on adaptive compression rate and a circuit system thereof are provided. In the method, a digital signal processor is used to process a video so as to frame-by-frame obtain statistical data, for example, a maximum of compressed data. The maximum of compressed data of a previous frame is used to determine a compression state of a current frame. The compression state of the frame allows the processor to decide a direction to adjust a compression ratio. Next, statistical data of the previous frame is used to decide a stride to adjust the compression ratio. The statistical data can be a maximum of compressed data and a quantization table scale referred to rendering a prediction curve that allows the processor to determine the stride. A compression ratio is then determined according to the direction and the stride of adjustment.

CROSS-REFERENCE TO RELATED PATENT APPLICATION

This application claims the benefit of priority to Patent ApplicationNo. 202011471798.X, filed on Dec. 14, 2020 in People's Republic ofChina. The entire content of the above identified application isincorporated herein by reference.

Some references, which may include patents, patent applications andvarious publications, may be cited and discussed in the description ofthis disclosure. The citation and/or discussion of such references isprovided merely to clarify the description of the present disclosure andis not an admission that any such reference is “prior art” to thedisclosure described herein. All references cited and discussed in thisspecification are incorporated herein by reference in their entiretiesand to the same extent as if each reference was individuallyincorporated by reference.

FIELD OF THE DISCLOSURE

The disclosure is related to a technology for video compression, andmore particularly to a method and a circuit system for video compressionthat is to adaptively adjust a compression rate based on degree ofcomplexity of a previous frame.

BACKGROUND OF THE DISCLOSURE

MJPEG (motion JPEG, Motion Joint Photographic Experts Group) is amultimedia format that is developed for frame-by-frame video compressionbased on JPEG technology. Main feature of MJPEG compression technologyis not to encode the difference among frames of a video but to compresseach individual frame. The MJPEG compression technology does notconsider the changes among the frames in the video. Therefore, the MJPEGcompression technology only requires low complexity of computation andlow computing power. The MJPEG compression technology has been widelyused in a webpage browser, a media player, a digital camera, a webcam,etc.

Conventional MJPEG compression technology adopts a fixed compressionrate for compressing a video, and has poor adaptability for variousscenes. When the MJPEG compression technology is used in a complexscene, it may cause the video appearing to be stuck in a frame or tohave a lost frame. When the MJPEG compression technology is used in asimple scene or a common scene, the definition of the video may bedropped due to a large compression rate. In general, the scenes in avideo should be frequently changed, and therefore the MJPEG compressiontechnology may not be appropriately adapted to the various scenes. Amore adaptable MJPEG video compression technology is required.

SUMMARY OF THE DISCLOSURE

For providing a video compression technology that is able to adapt tovarious changes of scenes by referring to statistical data of adjacentframes, provided in the disclosure is related to a method forcompressing video based on an adaptive compression rate and a circuitsystem thereof. The method is to adjust a compression rate adaptivelybased on a degree of complexity of images. The adaptive compression rateallows the compressed images to not only meet a frequency bandwidth butalso be presented with a best visual effect.

The circuit system includes a digital signal processor that applies aspecific compression technology. The circuit system can be disposed inan imaging device. Video data to be processed can be obtained through alens and a photosensor. The video data is processed frame-by-frame.After acquiring a maximum of compressed data of a previous frame fromthe video, the maximum of compressed data can be used to determine acompression state of a current frame. The compression rate of thecurrent frame needs not to be adjusted if the current frame is in astable state. A direction of adjustment can be obtained according to adirection tending toward a stable compression rate if the current frameis determined to be within an under-compression range or anover-compression range. The direction of adjustment allows thecompression rate of the current frame to be adjusted for tending towarda target compression rate.

Next, provided are several curves depicting relationships betweenmaximum of compressed data for multiple scenes and quantization tablescale. The scenes are such as a simple scene, a normal scene and acomplex scene. According to the maximum of compressed data and thequantization table scale of the previous frame, a predicted curve can beobtained by a linear interpolation method performed on the three sceniccurves.

According to the predicted curve and the maximum of compressed data inthe stable state, a target quantization table scale can be obtained. Adifference between the target quantization table scale and the currentquantization table scale of the predicted curve is referred to, so as todetermine a stride of adjustment. Whether the position of the maximum ofcompressed data is in a stable area determines the direction ofadjustment. A compression rate of the current frame is finallydetermined by the stride of adjustment and the direction of adjustment.In the imaging device, the video is compressed according to thecompression rate and outputted to a host via a connection interface.

Preferably, the maximum of compressed data is the maximum obtained byperforming compression on a preset number of pixels as a unit of each ofthe frames of the video. The maximum can be updated after frame loss orthe previous frame is compressed.

Further, when the maximum of compressed data of the previous frame ofthe video is determined lying in a stable range, the compression ratefor the current frame needs not to be adjusted. When the maximum ofcompressed data of the previous frame of the video is determined lyingin an under-compression range, the quantization table scale can bemagnified for reducing amount of data so as to adjust the maximum ofcompressed data toward the stable range. When the maximum of compresseddata of the previous frame of the video is determined lying in anover-compression range, the quantization table scale can be minified forincreasing amount of data so as to adjust the maximum of compressed datatoward the stable range.

These and other aspects of the present disclosure will become apparentfrom the following description of the embodiment taken in conjunctionwith the following drawings and their captions, although variations andmodifications therein may be affected without departing from the spiritand scope of the novel concepts of the disclosure.

BRIEF DESCRIPTION OF THE DRAWINGS

The described embodiments may be better understood by reference to thefollowing description and the accompanying drawings, in which:

FIG. 1 is a schematic diagram showing a target size for videocompression;

FIG. 2 is a schematic diagram depicting a state machine that is used todetermine an adjustment policy for a compression rate;

FIG. 3 shows several curves depicting relationships between the maximumof compressed data for different scenes and quantization table scaleaccording to one embodiment of the present disclosure;

FIG. 4 is a schematic diagram showing a piecewise linear function of apredicted curve according to one embodiment of the present disclosure;

FIG. 5 is a schematic diagram depicting an imaging device that employs acircuit system performing a method for video compression based on anadaptive compression rate according to one embodiment of the presentdisclosure;

FIG. 6 is a flow chart describing the method for video compression basedon the adaptive compression rate according to one embodiment of thepresent disclosure; and

FIG. 7 is another flow chart describing the method for video compressionbased on the adaptive compression rate according to one embodiment ofthe present disclosure.

DETAILED DESCRIPTION OF THE EXEMPLARY EMBODIMENTS

The present disclosure is more particularly described in the followingexamples that are intended as illustrative only since numerousmodifications and variations therein will be apparent to those skilledin the art. Like numbers in the drawings indicate like componentsthroughout the views. As used in the description herein and throughoutthe claims that follow, unless the context clearly dictates otherwise,the meaning of “a”, “an”, and “the” includes plural reference, and themeaning of “in” includes “in” and “on”. Titles or subtitles can be usedherein for the convenience of a reader, which shall have no influence onthe scope of the present disclosure.

The terms used herein generally have their ordinary meanings in the art.In the case of conflict, the present document, including any definitionsgiven herein, will prevail. The same thing can be expressed in more thanone way. Alternative language and synonyms can be used for any term(s)discussed herein, and no special significance is to be placed uponwhether a term is elaborated or discussed herein. A recital of one ormore synonyms does not exclude the use of other synonyms. The use ofexamples anywhere in this specification including examples of any termsis illustrative only, and in no way limits the scope and meaning of thepresent disclosure or of any exemplified term. Likewise, the presentdisclosure is not limited to various embodiments given herein. Numberingterms such as “first”, “second” or “third” can be used to describevarious components, signals or the like, which are for distinguishingone component/signal from another one only, and are not intended to, norshould be construed to impose any substantive limitations on thecomponents, signals or the like.

The present disclosure provides a method for video compression based onan adaptive compression rate, and a circuit system thereof. The methodcan be applied to MJPEG (motion JPEG, Motion Joint Photographic ExpertsGroup) video compression for adaptively adjusting a compression ratethereof according to degree of complexity of images. The adaptivecompression rate allows the compressed images to be presented with abest visual effect while meeting a bandwidth limitation.

For the above discussed shortcomings of the conventional technologies ofMJPEG video compression, provided in the disclosure is the methodapplied to MJPEG video compression with an adaptive compression rate.The method is particularly adapted to an image signal processor in animaging device. It should be noted that the conventional MJPEG videocompression technology usually uses a fixed compression rate in acompression process. However, the compression process using the fixedcompression rate may ignore related information between the adjacentframes for simplifying the compression process with the fixedcompression rate. The cost of simplifying the compression process is tohave poor scene adaptability and a larger compression size. Therefore,for solving the adaptability to various scenes having different degreesof complexity, in the method for video compression based on an adaptivecompression rate of the present disclosure, a quantization table scalecan be adaptively adjusted according to volume of information of each offrames in the video and prior statistical information. The compressionrate used for video compression is based on an adaptive compressionrate.

According to one of the objectives of the method for video compressionbased on an adaptive compression rate of the present disclosure, themethod enhances adaptability of the MJPEG video compression for adaptingto various scenes. The method is used to adaptively adjust a videocompression rate based on a complexity of a scene so as to perform videocompression under a bandwidth limitation. The adaptive compression rateallows the circuit system to prevent frame loss due to insufficientcompression and increase the compression rate as much as possible forproviding better quality video without frame loss.

In an aspect, the method for video compression based on an adaptivecompression rate can be applied to an imaging device which uses auniversal serial bus (USB) to transmit an MJPEG video. The imagingdevice includes an image signal processor (ISP). Reference is made toFIG. 5, which shows a circuit block diagram according to one embodimentof the present disclosure. The steps of the method can be referred tothe flow charts shown in FIG. 6 and FIG. 7. FIG. 1 through FIG. 4provide examples to illustrate the method for video compression with anadaptive compression rate according to the embodiments of the presentdisclosure.

The main concept of the method for video compression can be firstlyreferred to the flow chart shown in FIG. 6. The method can be applied tothe circuit system schematically shown in FIG. 5. In the circuit system,a digital signal processor is used to perform a software process or afirmware process. In the method, the circuit system receives a video(step S601, FIG. 6). The digital signal processor processes the videodata so as to extract information from a previous frame of the video andprocess the current frame. A statistical data regarding compression canbe obtained from volume of information of a previous frame, in which amaximum of compressed data of the previous frame can be obtained when apreset number of pixels (e.g., 8 lines of pixels) as a unit of theprevious frame are compressed with an initial compression rate (stepS603). A compression state of the previous frame can be determinedaccording to the maximum of compressed data of the previous frame. Thecompression state can be a stable compression state, anunder-compression state or an over-compression state. Therefore, adirection to adjust the compression rate can be determined according tothe compression state of the previous frame so as to make thecompression state of the current frame tending toward a stablecompression state. The adjusted compression rate allows the compressiondata size of the current frame to tend to a target compression data size(step S605), and can be referred to as in FIG. 2.

After the direction to adjust the compression rate is determined, astride of adjustment to adjust the compression rate is then determinedin the following method. When the circuit system obtains the statisticalvalue of the previous frame, e.g., the maximum of compressed data andthe quantization table scale of the previous frame, a predicted curvecan be determined by a mathematical method such as an interpolationmethod based on the relationship curves with respect to a simple scene,a normal scene and a complex scene (step S607). The predicted curve isused to determine the stride of adjustment for adjusting the compressionrate toward a target value (step S609). In particular, for rendering thepredicted curve based on the statistical value of the previous frame,relationship curves for illustrating relations of maximum of compresseddata and quantization table scale under multiple scenes such as thesimple scene, the normal scene and the complex scene are introduced. Thepredicted curve is obtained according to the maximum of compressed dataand the quantization table scale of the previous frame based on theabovementioned relationship curves. A target quantization table scale istherefore obtained. The stride of adjustment can be obtained byreferring to the quantization table scale of the previous frame and thetarget quantization table scale.

Finally, a compression rate is determined according to the direction ofadjustment and the stride of adjustment (step S611). That is, whenreferring to the statistical data of the previous frame, thequantization table scale can be adjusted for frame-by-frame adjustingthe compression rate.

According to one embodiment of the method for video compression, themethod can be applied to an electronic device that needs to performvideo compression. FIG. 5 shows an example of an electronic deviceincluding a circuit system for performing the method for videocompression based on an adaptive compression rate.

The imaging device 50 is a device for processing video data. The videodata is generated by capturing frame images through a lens 501 and aphotosensor 503 of the electronic device. A digital signal processor 505of the circuit system performs the method for video compression based onan adaptive compression rate by means of software or firmware. Theprocessed data can be stored to a memory 507 and then outputted via aconnection interface 509.

The connection interface 509 can be a wired or a wireless communicationinterface used to connect to an external host 511. The connectioninterface 509 is such as a universal serial bus (USB). The limitation ofa bandwidth of the connection interface 509 is one of factors that formthe limitations of video transmission. Through the adaptive quantizationtable scale, the method for video compression can use the bandwidth ofthe connection interface 509 adequately. The image signal processor 505is used to perform the method for video compression based on an adaptivecompression rate for determining a compression rate with respect to acurrent frame and producing a video which is compressed with thecompression rate. The video is then transmitted to the host 511. Thehost 511 then provides the video to be played after decompressing thevideo.

The following descriptions and drawings are related to the examples ofthe method for video compression based on an adaptive compression rate.

For example, with 8 lines of pixels as a unit to be compressed in adigital signal processor as an example, a maximum (8LineMaxSize) of thecompressed data of the 8 lines of pixels of every frame is obtainedafter a video is received. The maximum of compressed data acts as astatistical value that is used to measure a volume of information of thecurrent frame. The statistical value can be updated after frame loss orone of the frames is compressed.

For embodying adjustment of the adaptive compression rate, a target sizeis provided. An upper limit and a lower limit for adjusting the targetsize for every frame in the video can be referred to an adjustmentpolicy as illustrated in equation 1.

$\begin{matrix}\left\{ \begin{matrix}{{SizeTarget\_ H} = {\left( {1 + {StableRange}} \right) \times \left( {{UpperSize} \times {SizeTargetRatio}} \right)}} \\{{SizeTarget\_ L} = {\left( {1 - {StableRange}} \right) \times \left( {{UpperSize} \times {SizeTargetRatio}} \right)}}\end{matrix} \right. & {{Equation}\mspace{14mu} 1}\end{matrix}$

Equation 1 shows an algorithm for calculating a high target size(SizeTarget_H) and a low target size (SizeTarget_L) based on the targetsize (SizeTarget). The “UpperSize” indicates an upper limit of datatransmission formed by the connection interface within a period of timewhen the digital signal processor processes 8 lines of pixels. During apractical operation, a certain amount of bandwidth tolerance isreserved. For example, the target size setting for video compression canbe regarded as 70% of the upper limit of data transmission (UpperSize)due to the limitation of the connection interface. That is,“SizeTargetRatio”=70% in equation 1.

In the method, a target size is referred to for defining severalcompression ranges. Reference is made to FIG. 1, which is a schematicdiagram depicting target sizes for video compression. A stable range 101is defined between an up ratio and a down ratio (e.g., the up ratio is5% and the down ratio is 5%) based on a target size (SizeTarget) 11. Theupper limit of the stable range 101 can be a high target size(SizeTarget_H) 13, and the lower limit of the stable range 101 is a lowtarget size (SizeTarget_L) 15. An under-compression range 103 is definedin an upper range larger than a percentage (e.g., StableRange=5%) abovethe stable range 101. The under-compression range 103 represents a rangeindicative of a relatively small compression rate. An over-compressionrange 105 is defined in a lower range smaller than a percentage (e.g.,StableRange=5%) below the stable range 101. The over-compression range105 represents another range indicative of a relatively high compressionrate.

Next, according to the upper limit and the lower limit of a target sizeshown in FIG. 1, the compression rate for the video can be adaptivelyadjusted. The method is generally based on the well-defined stable range101, under-compression range 103 and over-compression range 105. In viewof equation 1, the adjustment policy can be referred to in the followingembodiments. Reference is further made to FIG. 2, which is a schematicdiagram depicting a state machine used to describe the adjustment policyfor adjusting the video compression rate.

According to volume of information of every frame, if the maximum ofcompressed 8 lines of pixels (8LineMaxSize) lies in the stable range101, as shown in FIG. 1, that is between a high target size 13 and a lowtarget size 15, it can be represented as“SizeTarget_L≤8LineMaxSize≤SizeTarget_H.” It can be inferred that it isnot necessary to adjust the compression rate of the current frame sincethe current frame is in a stable state (201, FIG. 2).

Further, if the maximum of compressed data of the previous frame lies inthe under-compression range 103, as shown in FIG. 1, that is the rangelarger than the high target size 13, it can be represented as“8LineMaxSize>SizeTarget_H.” It can be inferred that the current frameis in an under-compression state (203, FIG. 2). For making thecompression rate toward the stable state (201, FIG. 2), the quantizationtable scale (QTableScale) can be magnified according to the method forvideo compression based on an adaptive compression rate for reducing anamount of data.

Yet further, if the maximum of compressed data of the previous framelies in the over-compression range 105, as shown in FIG. 1, that is therange smaller than the low target size 15, it can be represented as“8LineMaxSize<SizeTarget_L.” It can be inferred that the current frameis in an over-compression state (205, FIG. 2). In the method, thequantization table scale (QTableScale) is minified for increasing anamount of data and increasing a utilization ratio of a buffer in theconnection interface, e.g., a buffer in a serial interface engine.Therefore, a higher quality video can be obtained.

It should be noted that an amount of magnifying or minifying thequantization table scale is limited by an upper limit and a lower limitReference is made to FIG. 2, a process incorporating an adjustmentpolicy depicted by a state machine based on the stable state, theunder-compression state and the over-compression state is shown. Thebroken lines shown in the diagram represent state transition when thescene changes and the solid lines represent the directions ofadjustment.

Because the scenes in an ordinary video are not always the same, themethod for video compression based on an adaptive compression rateembodies adaptive quantization table scale based on the volume ofinformation and statistic data of every frame and is able to provide abetter quality video when being adapted to various scenes. Thus, thebroken lines shown in FIG. 2 show that the maximum of compressed data ofthe frame can be transferred among the stable state 201, theunder-compression state 203 or the over-compression state 205 when thescene of the video changes. The compression rate for the frame is alsoadjusted adaptively with the adjustment of the quantization table scale.However, since the quantization table scale cannot be adjustedunlimitedly, the upper limit (ScaleMax) and the lower limit (ScaleMin)are used for limiting the adjustment of the quantization table scale.Three scenarios equivalent to the three states (201, 203 and 205) areillustrated in equations 2, 3 and 4. The stable state is met if any ofthe scenarios is satisfied.

With a digital signal processor which performs compression upon the 8lines of pixels as a unit as an example, the stable state can be definedin equation 2. A first scenario is that, when the maximum of compresseddata of the 8 lines of pixels (8LineMaxSize) is in between a low targetsize (SizeTarget_L) and a high target size (SizeTarget_H), thecompressed current frame lies in a stable state. A second scenario isthat, when the maximum of compressed data of the 8 lines of pixels(8LineMaxSize) is greater than or equal to a high target size(SizeTarget_H), and the quantization table scale (QTableScale) is equalto an upper limit (ScaleMax), the compressed current frame also lies ina stable state. A third scenario is that, when the maximum of compresseddata of the 8 lines of pixels (8LineMaxSize) is less than or equal to alow target size (SizeTarget_L), and the quantization table scale(QTableScale) equals to a lower limit (ScaleMin), the compressed currentframe also lies in a stable state.

Equation 2:

SizeTarget_L≤8LineMaxSize≤SizeTarget_H  1.

(8LineMaxSize≥SizeTarget_H)&&(QTableScale=ScaleMax)  2.

(8LineMaxSize≥SizeTarget_L)&&(QTableScale=ScaleMin)  3.

The under-compression state can be defined by equation 3. Under thefourth scenario, the compressed current frame is in an under-stablestate when the maximum of compressed data of 8 lines of pixels(8LineMaxSize) is higher than the high target size (SizeTarget_H), andthe quantization table scale (QTableScale) is smaller than an upperlimit (ScaleMax) of the quantization table scale.

Equation 3:

(8LineMaxSize>SizeTarget_H)&&(QTableScale<ScaleMax)  4.

The over-compression state can be defined by equation 4. Under the fifthscenario, the compressed current frame is in an over-stable state whenthe maximum of compressed data of 8 lines of pixels (8LineMaxSize) islower than the low target size (SizeTarget_L), and the quantizationtable scale (QTableScale) is greater than a lower limit (ScaleMin) ofthe quantization table scale.

Equation 4:

(8LineMaxSize<SizeTarget_L)&&(QTableScale>ScaleMin)  5.

The above-described scenarios can be applied to a state machine foradjustment policy shown in FIG. 2. The state machine can be used toobtain a direction of adjustment. In addition, a stride of adjustment isalso required to be obtained. Reference is made to FIG. 3, which shows acurve diagram illustrating relationships between the maximum ofcompressed data of a preset number of lines of pixels under variousscenes and the quantization table scale according to one embodiment ofthe present disclosure. The curves shown in the diagram illustrate therelationships between the maximum of compressed data of multiple linesof pixels and quantization table scale (QTableScale) under a first scene301 (e.g., a simple scene), a second scene 302 (e.g., a normal scene)and a third scene 303 (e.g., a complex scene). The maximum of compresseddata is such as the maximum of compressed 8 lines of pixels. It shouldbe noted that the horizontal axis of the curve diagram indicates thequantization table scale and the vertical axis thereof indicates themaximum of compressed data.

Based on the relationships between multiple scenes such as the firstscene 301 (e.g., a simple scene), the second scene 302 (e.g., a normalscene) and the third scene 303 (e.g., a complex scene) shown in FIG. 3,the statistical value such as the maximum of compressed data (e.g.,8LineMaxSize) and the quantization table scale (QTableScale) of theprevious frame can be used to obtain a predicted curve 305 by performinga linear interpolation method upon the statistical values of the threecurves. The predicted curve 305 acts as a model curve for the subsequentcalculation. As the dotted lines shown in FIG. 3, the curves areapproximated to a piecewise linear functions within a range“QTableScale∈[1, 255]” including a first section 31, a second section 32and a third section 33. The intervals between the sections 31, 32 and 33are smaller if the quantization table scale (i.e., the horizontal axis)is smaller. Conversely, the intervals between the sections 31, 32 and 33are larger if the quantization table scale is larger. FIG. 4 shows apiecewise linear function (horizontal axis: quantization table scale;vertical axis: the maximum of compressed data) for the predicted curveaccording to one embodiment of the disclosure.

According to the prediction curve 40 shown in FIG. 4, with the digitalsignal processor performing compression upon 8 lines of pixels as anexample, if the maximum of compressed data of 8 lines of pixels(8LineMaxSize) of the previous frame is “A”, which indicates a state ofthe previous frame, the corresponding quantization table scale islabeled as “401” (QTableScale_Cur). According to the predicted curve 40,the target size (SizeTarget) 405 under the stable state (201, FIG. 2) Tcorresponds to the target quantization table scale (QTableScale_Tar)403.

However, if the target size 405 and the predicted curve 40 do notintersect, and the predicted curve 40 is below the target size 405, thescene is determined as being too simple. In the meantime, the targetquantization table scale (QTableScale_Tar) 403 is set to be equal to thelower limit (ScaleMin) of the quantization table scale (i.e.,QTableScale_Tar=ScaleMin). The stride of adjustment is represented asTuneStep=|QTableScale_Tar−QTableScale_Cur|. The compression size of thevideo can be adjusted to the stable range according to the direction ofadjustment (e.g., the over-compression state is adjusted to the stablestate) and the stride of adjustment (i.e., between 401 and 403).

According to the above embodiment, reference is made to FIG. 7, whichshows a flow chart describing the method for video compression based onan adaptive compression rate according to one embodiment of the presentdisclosure.

The predicted curve can be obtained according to a prior information fora specific scene, the quantization table scale of the previous frame andthe maximum of compressed data of the previous frame. The predictedcurve can be regarded as a model curve and can be updated after frameloss or the previous frame is compressed. An appropriate adjustmentpolicy of the QScaleTable is adopted based on determination of thestable state, the under-compression state or the over-compression state.On one hand, the method can effectively enhance adaptability withrespect to the various scenes for the MJPEG video compression technologyand allow the circuit system to prevent frame loss due to insufficientcompression. On the other hand, the method can make full use ofbandwidth and improve video quality without frame loss and stuttering

Reference is next made to FIG. 7, which shows a flow chart describingthe method for video compression based on an adaptive compression ratebased on the above embodiments.

The method is mainly performed by a digital signal processor in animaging device. A video is received (step S701), and a maximum ofcompressed data of multiple lines of pixels of a previous frame isobtained (step S703). According to one of the embodiments, in themethod, the maximum of compressed data can be obtained by performingcompression upon a preset number of pixels (e.g., 8 lines of pixels) asa unit of each of frames of the video.

A compression state of the current frame can be determined based on themaximum of the compressed data of the previous frame. The compressionstate can be defined as the stable range, the under-compression rangeand the over-compression range as shown in FIG. 1 (step S705). Next,referring to the state machine of adjustment policy for a compressionrate shown in FIG. 2, a direction of adjustment is determined accordingto the compression state of the current frame (step S707). In themeantime, as shown in FIG. 3, the curves depicting relationships betweenthe maximum compressed data under multiple scenes and the quantizationtable scale are introduced (step S709).

The multiple scenes can be classified into a simple scene, a normalscene and a complex scene. The curves are processed by a linearinterpolation method so as to render a predicted curve, as shown in FIG.4 (step S711). As compared to the predicted curve shown in FIG. 4, atarget size under a stable state can be obtained so as to provide atarget quantization table scale (step S713). A current quantizationtable scale is obtained when corresponding to the statistical value ofthe previous frame over the predicted curve (step S715). A stride ofadjustment is determined according to the target quantization tablescale and the current quantization table scale (step S717). Finally, acompression rate for the current frame is determined based on thedirection of adjustment and the stride of adjustment, and thecompression rate is applied so as to perform video compression (stepS719).

According to the flow described above, one of the objectives of themethod for video compression based on an adaptive compression rate is toenhance adaptability of the MJPEG video compression technology, in whichthe compression rate is adaptively adjusted under a bandwidthlimitation. The adaptive compression rate allows the circuit system toprevent frame loss due to insufficient compression and increasebandwidth utilization as much as possible for providing better qualityvideo without frame loss.

The foregoing description of the exemplary embodiments of the disclosurehas been presented only for the purposes of illustration and descriptionand is not intended to be exhaustive or to limit the disclosure to theprecise forms disclosed. Many modifications and variations are possiblein light of the above teaching.

The embodiments were chosen and described in order to explain theprinciples of the disclosure and their practical application so as toenable others skilled in the art to utilize the disclosure and variousembodiments and with various modifications as are suited to theparticular use contemplated. Alternative embodiments will becomeapparent to those skilled in the art to which the present disclosurepertains without departing from its spirit and scope.

What is claimed is:
 1. A method for video compression based on anadaptive compression rate, comprising: receiving a video; obtaining amaximum of compressed data of a previous frame from the video;determining a compression state of a current frame according to themaximum of compressed data of the previous frame; determining adirection of adjustment to adjust a compression rate according to acompression state of the previous frame so as to cause a compressionrate of the current frame to be closer to a target compression rate;introducing relationship curves between a maximum of compressed dataunder multiple scenes and a quantization table scale, and rendering apredicted curve according to the maximum of compressed data of theprevious frame and a quantization table scale of the previous frame;obtaining a current quantization table scale by comparing the maximum ofcompressed data of the previous frame with the predicted curve;determining a stride of adjustment according to a difference between atarget quantization table scale and the current quantization table scaleof the predicted curve; and determining the compression rate of thecurrent frame according to the direction of adjustment and the stride ofadjustment, and compressing the video with the compression rate.
 2. Themethod according to claim 1, wherein the maximum of compressed data is amaximum obtained by performing compression upon a preset number ofpixels as a unit of each of frames of the video.
 3. The method accordingto claim 2, wherein, when maximum of compressed data of each of theframes is obtained, the maximum of compressed data is updated afterframe loss or after the previous frame is compressed.
 4. The methodaccording to claim 1, wherein a digital signal processor applying themethod for video compression based on the adaptive compression rateperforms compression upon 8 lines of pixels as a unit, and the maximumof compressed data is a maximum of the compressed 8 lines of pixels. 5.The method according to claim 1, wherein a target size, a high targetsize, and a low target size used to determine the compression state aredetermined according to an upper limit of data transmission and in viewof a bandwidth tolerance which is reserved for practical operation. 6.The method according to claim 5, wherein a stable range is defined as arange based on the target size, an under-compression range is defined asa range higher the high target size, and an over-compression range isdefined as a range lower the low target size.
 7. The method according toclaim 6, wherein, based on the well-defined stable range, theunder-compression range and the over-compression range, the maximum ofcompressed data of each of the frames is used to determine thecompression state as a stable compression state, an under-compressionstate, or an over-compression state.
 8. The method according to claim 7,wherein, a target quantization table scale of the previous frame isobtained when comparing the target size in the stable range with thepredicted curve, and the stride of adjustment is determined according tothe target quantization table scale.
 9. The method according to claim 8,wherein, when the maximum of compressed data of the current frame in thevideo is determined in the stable range, the compression rate for thecurrent frame needs not to be adjusted.
 10. The method according toclaim 8, wherein, when the maximum of compressed data of the previousframe of the video is determined to be lying in the under-compressionrange, the quantization table scale is magnified for reducing amount ofdata, so as to adjust the compression rate toward the stable range. 11.The method according to claim 8, wherein, when the maximum of compresseddata of the previous frame of the video is determined to be lying in theover-compression range, the quantization table scale can be minified forincreasing amount of data so as to adjust the compression rate towardthe stable range.
 12. The method according to claim 11, wherein anamount of magnifying or minifying the quantization table scale islimited by an upper limit and a lower limit.
 13. The method according toclaim 7, wherein the maximum of compressed data of each of frames of thevideo shifts among the stable compression state, the under-compressionstate, and the over-compression state with change of the scene.
 14. Themethod according to claim 13, wherein, in the step of introducing thecurves depicting relationships between the maximum of compressed dataunder multiple scenes and the quantization table scale, the multiplescenes include a simple scene, a normal scene and a complex scene, and apredicted curve is obtained through a linear interpolation mannerperformed on curves of the three scenes.
 15. A circuit system,comprising: a digital signal processor, performing a method for videocompression based on an adaptive compression rate through a softwareprocess or a firmware process, wherein the method includes: receiving avideo; obtaining a maximum of compressed data of a previous frame fromthe video; determining a compression state of a current frame accordingto the maximum of compressed data of the previous frame; determining adirection of adjustment to adjust a compression rate according to acompression state of the previous frame so as to make a compression rateof the current frame toward a target compression rate; introducingcurves depicting relationships between maximum of compressed data undermultiple scenes and the quantization table scale, and rendering apredicted curve according to a maximum of compressed data of theprevious frame and a quantization table scale of the previous frame;obtaining a current quantization table scale by comparing the maximum ofcompressed data of the previous frame with the predicted curve;determining a stride of adjustment according to a difference between atarget quantization table scale and the current quantization table scaleof the predicted curve; and determining the compression rate of thecurrent frame according to the direction of adjustment and the stride ofadjustment, and compressing the video with the compression rate.
 16. Thecircuit system according to claim 15, wherein the circuit system isdisposed in an imaging device, the video is acquired through a lens anda photosensor of the imaging device; wherein the imaging device outputsvia a connection interface the video which is compressed with thecompression rate determined by the method.
 17. The circuit systemaccording to claim 16, wherein, in the method for video compressionbased on the adaptive compression rate, a target size, a high targetsize and a low target size used to determine the compression state aredetermined according to an upper limit of data transmission due tolimitation of the connection interface in view of a bandwidth tolerancewhich is reserved for practical operation.
 18. The circuit systemaccording to claim 17, wherein the stable range is defined based on thetarget size, an under-compression range is defined as a range higherthan the high target size, and an over-compression range is defined as arange lower than the low target size.
 19. The circuit system accordingto claim 18, wherein the target quantization table scale of the previousframe is obtained when comparing the target size in the stable rangewith the predicted curve, and the stride of adjustment is determinedaccording to the target quantization table scale.
 20. The circuit systemaccording to claim 18, wherein, based on the well-defined stable range,the under-compression range and the over-compression range, the maximumof compressed data of each of frames is used to determine thecompression state as a stable compression state, an under-compressionstate, or an over-compression state.